package com.gobang.common.exception;

/**
 * 游戏核心模块异常类
 * 处理游戏相关的业务异常
 * 
 * @author System
 * @since 1.0.0
 */
public class GameException extends BaseException {

    /**
     * 构造函数 - 使用ErrorCode枚举
     *
     * @param errorCode 错误码枚举
     */
    public GameException(ErrorCode errorCode) {
        super(errorCode);
    }

    /**
     * 构造函数 - 使用ErrorCode枚举和自定义消息
     *
     * @param errorCode 错误码枚举
     * @param customMessage 自定义错误消息
     */
    public GameException(ErrorCode errorCode, String customMessage) {
        super(errorCode, customMessage);
    }

    /**
     * 构造函数 - 包含原因异常
     *
     * @param errorCode 错误码枚举
     * @param cause 原因异常
     */
    public GameException(ErrorCode errorCode, Throwable cause) {
        super(errorCode, cause);
    }

    // 便捷方法
    public static GameException gameRoomNotFound() {
        return new GameException(ErrorCode.GAME_ROOM_NOT_FOUND);
    }

    public static GameException gameRoomFull() {
        return new GameException(ErrorCode.GAME_ROOM_FULL);
    }

    public static GameException gameNotStarted() {
        return new GameException(ErrorCode.GAME_NOT_STARTED);
    }

    public static GameException gameAlreadyStarted() {
        return new GameException(ErrorCode.GAME_ALREADY_STARTED);
    }

    public static GameException gameAlreadyEnded() {
        return new GameException(ErrorCode.GAME_ALREADY_ENDED);
    }

    public static GameException gameMoveInvalid() {
        return new GameException(ErrorCode.GAME_MOVE_INVALID);
    }

    public static GameException gameNotYourTurn() {
        return new GameException(ErrorCode.GAME_NOT_YOUR_TURN);
    }

    public static GameException gamePositionOccupied() {
        return new GameException(ErrorCode.GAME_POSITION_OCCUPIED);
    }

    public static GameException gamePositionOutOfBounds() {
        return new GameException(ErrorCode.GAME_POSITION_OUT_OF_BOUNDS);
    }

    public static GameException gameBoardStateError() {
        return new GameException(ErrorCode.GAME_BOARD_STATE_ERROR);
    }

    public static GameException gamePlayerNotInRoom() {
        return new GameException(ErrorCode.GAME_PLAYER_NOT_IN_ROOM);
    }

    public static GameException gameSurrenderFailed() {
        return new GameException(ErrorCode.GAME_SURRENDER_FAILED);
    }

    public static GameException gameWinCheckError() {
        return new GameException(ErrorCode.GAME_WIN_CHECK_ERROR);
    }

    public static GameException gameStateSyncError() {
        return new GameException(ErrorCode.GAME_STATE_SYNC_ERROR);
    }

    public static GameException gameTimerError() {
        return new GameException(ErrorCode.GAME_TIMER_ERROR);
    }
} 